home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1999 Spring / macformat-077.iso / Shareware Plus / Development / Akua Sweets 131 / Akua Sweets Examples / Appearance (In Development) / Desktop Slides < prev    next >
Encoding:
Text File  |  1999-03-04  |  6.3 KB  |  254 lines  |  [TEXT/ToyS]

  1. -- User setable
  2. property kasSwitchEvery : 15 -- Seconds
  3. property kasAllowedTypes : {"PICT", "JPEG", "JIFF", "fold"}
  4. property kasTest : false -- In editing evironment
  5. property kasLoop : true -- Loop indefinitely
  6. property kasProgress : true -- show progress
  7.  
  8. -- Internal Globals
  9. property gasCurrentPaths : {} -- List of current folders
  10. property gasCurrentPathIdx : 0 -- Index into that
  11. property gasCurrentPathCnt : 0 -- Number of items of that
  12.  
  13. property gasCurrentItems : {} -- List of current items
  14. property gasCurrentItemIdx : 0 -- Index into that
  15. property gasCurrentItemCnt : 0 -- Number of items of that
  16.  
  17. property gasDadsList : {-1} -- Push/Pop list of passed gasCurrentItemIdx
  18. property gasDadsIdx : 1 -- Index into that
  19. property gasDadsCnt : 1 -- The number of that
  20.  
  21. property gasFolder : "" -- Current folder we are working in…
  22. property gasFileName : "" -- Current file name
  23.  
  24. property kasProgLoc : {0, 0} -- Last progress location
  25.  
  26. global gasScreenCnt -- Number of monitors
  27. global gasDoneOne -- Have we done at least one?
  28. global gasProgW -- Progress window
  29.  
  30.  
  31. on run
  32.     -- Do all disks?
  33.     if (gasCurrentPaths is {}) then
  34.         set dList to list disks
  35.         repeat with d in dList
  36.             set gasCurrentPaths to gasCurrentPaths & ((d & ":") as alias)
  37.         end repeat
  38.         set gasCurrentPathCnt to the number of items of gasCurrentPaths
  39.     end if
  40.     
  41.     set gasProgW to 0
  42.     set gasDoneOne to false
  43.     set gasScreenCnt to CountScreens()
  44.     
  45.     if (kasTest) then
  46.         repeat while true
  47.             idle
  48.         end repeat
  49.     end if
  50. end run
  51.  
  52.  
  53. on open fsObjs
  54.     set gasCurrentPaths to {}
  55.     set gasCurrentPathIdx to 0
  56.     
  57.     set gasCurrentItems to {}
  58.     set gasCurrentItemIdx to 0
  59.     
  60.     -- Split fsObjs into Paths and Items
  61.     repeat with fsItem in fsObjs
  62.         set fsObj to resolve server alias fsItem
  63.         
  64.         if (catalog kind of (basic info for fsObj)) is a folder then
  65.             set gasCurrentPaths to gasCurrentPaths & fsObj
  66.         else if kasAllowedTypes contains (system type of (basic info for fsObj)) then
  67.             set gasCurrentItems to gasCurrentItems & fsObj
  68.         end if
  69.     end repeat
  70.     
  71.     set gasCurrentPathCnt to the number of items of gasCurrentPaths
  72.     set gasCurrentItemCnt to the number of items of gasCurrentItems
  73.     
  74.     set gasDadsList to {-1}
  75.     set gasDadsIdx to 1
  76.     set gasDadsCnt to 1
  77.     
  78.     set gasProgW to 0
  79.     set gasDoneOne to false
  80.     set gasScreenCnt to CountScreens()
  81.     
  82.     if (kasTest) then
  83.         repeat while true
  84.             idle
  85.         end repeat
  86.     end if
  87. end open
  88.  
  89.  
  90. on idle
  91.     if (kasProgress and (gasProgW is 0)) then ¬
  92.         set gasProgW to display info titled ¬
  93.             "Desktop Slides" message ¬
  94.             "…" located at kasProgLoc
  95.     
  96.     -- Server gone offline?
  97.     if (gasFolder is not "") then
  98.         try
  99.             set gasFolder to resolve server alias gasFolder
  100.         on error err
  101.             if (kasProgress) then
  102.                 display info gasProgW message err at line 2
  103.                 display info gasProgW message "OFFLINE!?!" at line 3
  104.             end if
  105.             beep
  106.             return kasSwitchEvery * 10
  107.         end try
  108.     end if
  109.     
  110.     repeat with i from 1 to gasScreenCnt
  111.         set myImage to GetNextImage()
  112.         try
  113.             tell application "Schreibtischhintergrund" to set desktop picture to myImage for screen i
  114.         on error
  115.             beep
  116.         end try
  117.     end repeat
  118.     
  119.     -- Hide Desktop Pictures...
  120.     if (not gasDoneOne) then
  121.         set gasDoneOne to true
  122.         HideApp("dkpx")
  123.     end if
  124.     
  125.     return kasSwitchEvery
  126. end idle
  127.  
  128.  
  129. on CountScreens()
  130.     try
  131.         -- Needs Jon's Commands
  132.         return number of items of («event JonsScrL»)
  133.     on error
  134.     end try
  135.     
  136.     return 1
  137. end CountScreens
  138.  
  139.  
  140. on HideApp(appID)
  141.     tell application "Finder"
  142.         try
  143.             set pList to (the name of every process whose creator type is appID)
  144.         on error
  145.             return
  146.         end try
  147.         
  148.         if (class of pList is not list) then set pList to {pList}
  149.         
  150.         repeat with p in pList
  151.             try
  152.                 set visible of process named p to false
  153.             on error
  154.                 beep
  155.             end try
  156.         end repeat
  157.     end tell
  158. end HideApp
  159.  
  160.  
  161. on GetNextImage()
  162.     -- Check dropped images…
  163.     if (gasCurrentPathIdx is 0) then
  164.         set gasCurrentItemIdx to gasCurrentItemIdx + 1
  165.         repeat with gasCurrentItemIdx from gasCurrentItemIdx to gasCurrentItemCnt
  166.             set myFile to item gasCurrentItemIdx of gasCurrentItems
  167.             set fInfo to the basic info for myFile
  168.             if (kasAllowedTypes contains (system type of fInfo)) then return myFile
  169.         end repeat
  170.         GetNextPath()
  171.     end if
  172.     
  173.     -- Find next image to process
  174.     repeat while not GetNextFolderImage()
  175.     end repeat
  176.     
  177.     -- Return current image
  178.     -- set myName to (item gasCurrentItemIdx of gasCurrentItems) -- Gives an error?!?
  179.     if (kasProgress) then ¬
  180.         set kasProgLoc to screen location of ¬
  181.             (display info gasProgW message gasFileName at line 1)
  182.     
  183.     return ((gasFolder as string) & gasFileName) as alias
  184. end GetNextImage
  185.  
  186.  
  187. on GetNextPath()
  188.     set gasCurrentPathIdx to gasCurrentPathIdx + 1
  189.     if (gasCurrentPathIdx > gasCurrentPathCnt) then
  190.         set gasCurrentPathIdx to 1
  191.         if (not kasLoop) then quit
  192.     end if
  193.     SetCurrentFolder(item gasCurrentPathIdx of gasCurrentPaths)
  194. end GetNextPath
  195.  
  196.  
  197. on SetCurrentFolder(newFold)
  198.     set gasFolder to newFold
  199.     set gasCurrentItems to the entries in newFold whose types are in kasAllowedTypes
  200.     set gasCurrentItemIdx to 0
  201.     set gasCurrentItemCnt to the number of items of gasCurrentItems
  202. end SetCurrentFolder
  203.  
  204.  
  205. on GetNextFolderImage()
  206.     -- Next item
  207.     set gasCurrentItemIdx to gasCurrentItemIdx + 1
  208.     
  209.     -- Pop a folder?
  210.     if (gasCurrentItemIdx > gasCurrentItemCnt) then
  211.         -- Top of list?
  212.         if (gasDadsIdx is 1) then
  213.             GetNextPath()
  214.         else
  215.             -- Pop one
  216.             SetCurrentFolder(parent spec of (extended info for gasFolder))
  217.             -- Restore index from daddy list
  218.             set gasCurrentItemIdx to item gasDadsIdx of gasDadsList
  219.             set gasDadsIdx to gasDadsIdx - 1
  220.         end if
  221.         return false
  222.     end if
  223.     
  224.     if (kasProgress) then ¬
  225.         set kasProgLoc to screen location of ¬
  226.             (display info gasProgW message (gasFolder as string) at line 3)
  227.     
  228.     repeat with gasCurrentItemIdx from gasCurrentItemIdx to gasCurrentItemCnt
  229.         set myItem to item gasCurrentItemIdx of gasCurrentItems
  230.         set myKind to (the kind of entry in gasFolder named myItem)
  231.         
  232.         if myKind is a folder then
  233.             -- Push current index
  234.             set gasDadsIdx to gasDadsIdx + 1
  235.             if (gasDadsIdx > gasDadsCnt) then
  236.                 set gasDadsList to gasDadsList & gasCurrentItemIdx
  237.                 set gasDadsCnt to gasDadsCnt + 1
  238.             else
  239.                 set item gasDadsIdx of gasDadsList to gasCurrentItemIdx
  240.             end if
  241.             -- Do this folder instead
  242.             SetCurrentFolder(((gasFolder as string) & myItem) as alias)
  243.             return false
  244.         else if (myKind is a file) then -- Don't do aliases for now
  245.             set gasFileName to myItem
  246.             return true
  247.         else
  248.             -- Don't do aliases for now…
  249.         end if
  250.     end repeat
  251.     
  252.     return false
  253. end GetNextFolderImage
  254.